<head>
    <title>作业一</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
    <!-- and it's easy to individually load additional languages -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/go.min.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
</head>
<pre>
    <code>
class AuthClass:

def __init__(self, name, pwd) -> None:
    self.name = name
    self.pwd = pwd

def auth(self):
    if self.name == "python" and self.pwd == "123":
        return True
    else: return False

def auth_before(f):
    # * 包装
    def inner(user: AuthClass):
        if not user.auth():
            print("用户名或密码错误")
            return False
        else:
            # * 解包
            return f(user)
    return inner

@auth_before
def f1(user: AuthClass):
    return "用户%s登录成功" % user.name

if __name__ == "__main__":
    user1 = AuthClass("哼哼哼嗷嗷嗷", "1234")
    user2 = AuthClass("python", "123")
    print(f1(user1))
    print(f1(user2))
    </code>
</pre>